<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>北京青少年模拟政协</title>
    <link rel="stylesheet" href="../css/aaa.css">
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/bug.css">
</head>

<body>
    <header>
        <section class="head">
            <div class="container">
                <img class="logo" width="75" height="75" src="../images/h3.png" alt="">
                <img width="292" src="../images/h1.png" alt="">
                <div class="nav">
                    <a class="item" href="index.html">
                        首页
                    </a>
                    <a class="item cur" href="proposalList.html">
                        提案中心
                    </a>

                    <a class="item" href="news.html">
                        新闻资讯
                    </a>
                    <a class="item " href="lib.html">
                        资料库
                    </a>
                </div>
            </div>
        </section>
    </header>
    <section class="prompt">
        <div class="containersm">忘记密码</div>
    </section>
    <section class="inps changePhone">
        <div class="index8_wrap">
            <div class="containersm">
                <div class="num">
                    <div class="item cur">1</div>
                    <div class="item cur">2</div>
                    <div class="item">3</div>
                </div>
                <div class="inpBox">
                    <p class="position_p" style="width: 150px;left: -150px;">请输入手机号：</p>
                    <input id="phone" name="phone" type="text" placeholder="不能为空">
                    <div id="btnvelid" class="btn">
                        获取手机验证码
                    </div>
                </div>
                <div class="inpBox">
                    <p class="position_p">
                        <span>*</span>手机校验码：</p>
                    <input name="validCode" type="text" placeholder="不能为空">
                </div>
                <div class="inpBox">
                    <p class="position_p">
                        <span>*</span>设置新密码：</p>
                    <input name="password" type="text" placeholder="不能为空">
                </div>
                <br>
                <br>
                <div class="keepBtnBox">
                    <div id="submit" class="keepBtn cur">确认修改</div>
                    <a href="index.html" class="keepBtn">返回</a>
                </div>
            </div>
        </div>
    </section>
    <script src="../js/jquery-2.1.4.min.js"></script>
    <script src="../js/base.js"></script>
    <script>
        // $.Fg.checkInfo();
        var time = 60;
        var timer = null;
        function updatesmstime() {
            time = time - 1;
            if (time > 0) {
                $("#btnvelid").html("(" + time + ")秒后发送");
            } else {
                window.clearInterval(timer);
                $("#btnvelid").html("重新发送");
                $("#btnvelid").attr("opstatus", 0);
            }
        }
        $(function () {

            $('#change').click(function () {
                // $('#codeImg').reload();
                $('#codeImg').attr('src', 'http://mnzx.dfgy.ltd:3999/?' + Math.random().toString(36).substr(2))
            });

            /* 1: 学生 2: 委员 */
            var type = $.Fg.getSession($.Fg.keys.USERTYPE);
            function save() {

                var _data = {
                    phone: $('input[name=phone]').val(),
                    validCode: $('input[name=validCode]').val(),
                    password: $('input[name=password]').val()
                }
                if (_data.phone == "") {
                    $.Fg.alert("请输入手机号码");
                    return false;
                } else if (_data.validCode == "") {
                    $.Fg.alert("请输入短信验证码");
                    return false;
                } else if (_data.password == "") {
                    $.Fg.alert("请输入新密码");
                    return false;
                } else {
                    $.Fg.ajax('student/action_forget_password', {
                        method: "PUT",
                        data: _data,
                        isLogin: true,
                        success: function (data) {
                            console.log(data);
                            $.Fg.alert("操作成功");
                        },
                        error: function () {
                            $.Fg.ajax('expert/action_forget_password', {
                                data: _data,
                                method: 'PUT',
                                isLogin: true,
                                success: function (data) {
                                    $.Fg.alert('操作成功');
                                }
                            });
                        }
                    });
                }
            }
            $("#submit").click(function () {
                save();
            });
            $(document).ready(function () {
                /**
                 * 获取验证码
                 */
                $("#btnvelid").click(function () {
                    var o = $(this);
                    var status = o.attr("opstatus");
                    if (status === "1") {
                        return false;
                    }
                    var phone = $("input[name='phone']").val();
                    if (phone.length === 0) {
                        $.Fg.alert("请填写手机号");
                        return false;
                    }
                    $.Fg.ajax("verification", {
                        method: "POST",
                        async: true,
                        data: {
                            phone: phone
                        },
                        isLogin: true,
                        success: function (data) {
                            console.log(data);
                            o.attr("opstatus", 1);
                            time = 60;
                            o.html("(60)秒后发送");
                            timer = setInterval("updatesmstime()", 1000);
                        }
                    });
                });
            });
        });
    </script>
</body>

</html>